﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace Design
{
    public class textstring
    {
        public static readonly DependencyProperty StrtbProperty;
        public static string Getstring(DependencyObject obj)
        {
            return (string)obj.GetValue(StrtbProperty);
        }
        public static void Setstring(DependencyObject obj, string value)
        {
           
            obj.SetValue(StrtbProperty, value);
        }
        static textstring()
    {
       
      //register attached dependency property

        var metadata = new PropertyMetadata((string)null, OnTextChanged);
      StrtbProperty = DependencyProperty.RegisterAttached("Strtb",
                                                          typeof (string),
                                                          typeof(textstring), metadata);
    }

        private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var tb = d as TextBlock;
            if (tb == null) return;
            tb.Text = e.NewValue.ToString();
        }
    }
}
